var db = require('../../common/basicConnection');

let { addUser_sql, deleteUser_sql, queryUser_sql } = require('./users_sql.js')

/**
 * 增加用户Action
 */
function add(req, res, next){
    // 获取前台页面传过来的参数
    var param = req.query || req.params || req.body;
    console.log(req,res);
    let sqlparam = [
        // param.headerImg ? param.headerImg : "",
        param.username ? param.username : "",
        // param.password ? param.password : "",
        // param.addres ? param.addres : "",
        // param.sex ? param.sex : 1,
        // param.mobile ? param.mobile : "",
        // param.email ? param.email : "",
    ]

    // 执行Query
    db.queryArgs(addUser_sql, sqlparam, function(error, result) {
            if (error) throw error;
            result = {
                code: 200,
                msg:'successful'
            };
            // let r =  result.createResult(true, success);
            // 以json形式，把操作结果返回给前台页面
            db.doReturn(res, result);
        }
    );
}

// exports
module.exports = {
    add: add
};